﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WcfGeebaServer.DBDAL;

namespace WcfGeebaServer.Users
{
    [Serializable]
    public enum UserType
    {
        Admin = 0,
        Moderator,
        Member,
        Guest
    }

    [Serializable]
    public class User
    {
        #region Fields

        private string username;
        private UserType userType;

        #endregion

        #region DataMembers

        public string Username
        {
            get { return username; }
            private set { username = value; }
        }

        public UserType UserType
        {
            get { return MemberDA.getMemberDA().GetUserType(this.username); }
            set { userType = value; }
        }


        #endregion

        #region Ctors

        public User(string username)
        {
            this.Username = username;
            this.UserType = Users.UserType.Guest;
        }

        #endregion

        #region Methods

        public override int GetHashCode()
        {
            return this.Username.GetHashCode();
        }

        public override bool Equals(Object obj)
        {
            if (obj == null)
            {
                return false;
            }

            User u = obj as User;
            if ((Object)u == null)
            {
                return false;
            }

            return this.Username.Equals(u.Username);
        }

        #endregion
    }
}
